var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIBase"),
    s = t("UIConfig"),
    c = t("UIManager"),
    p = cc._decorator,
    l = p.ccclass,
    d =
        (p.property,
        p.menu,
        (function (t) {
            i(e, t);
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            e.prototype.onShowEnd = function () {
                AdView.preloadRewardVedioAd();
                this.setView(0);
                QReport.send("1004", 1);
            };
            e.prototype.setView = function (t) {
                this._DeclarePanel.active = 0 == t;
                this._inputPanel.active = 1 == t;
                this._certifyOKPanel.active = 2 == t;
            };
            e.prototype._onNextBtnTouchEnd = function () {
                this.setView(1);
            };
            e.prototype._onSubmitBtnTouchEnd = function () {
                var t = this._iDCardEditBox.$EditBox.string;
                this._nameEditBox.$EditBox.string.length <= 1 &&
                    c.default.open(s.UIID.UIToast, {msg: "姓名或者身份证号码不正确"});
                if (15 == t.length || 18 == t.length) {
                    switch (this.isValidIDCard(t, Date.now())) {
                        case 0:
                            c.default.open(s.UIID.UIToast, {msg: "姓名或者身份证号码不正确"});
                            return;
                        case 2:
                            c.default.open(s.UIID.UIToast, {msg: "改身份未成年"});
                            return;
                    }
                    if (t.length > 10) {
                        var e = t.substring(6, 8);
                        if ("19" != e && "20" != e) {
                            c.default.open(s.UIID.UIToast, {msg: "姓名或者身份证号码不正确"});
                            return;
                        }
                    }
                    var o = GameCof.token,
                        a =
                            "https://xmtx.yonyow.com/api.user.v2/fcmSubmit?realname=" +
                            this._nameEditBox.$EditBox.string +
                            "&identity=" +
                            t +
                            "&token=" +
                            o;
                    a = encodeURI(a);
                    this.checkLogin(t, t, a);
                } else c.default.open(s.UIID.UIToast, {msg: "姓名或者身份证号码不正确"});
            };
            e.prototype.checkLogin = function (t, e, o) {
                var a = this,
                    i = GameCof.getLastId();
                GameBaseManager.checkLogin(t, i, o, function (t, e) {
                    if ("stalk" != e) a.checkCanShiMin(t, e);
                    else {
                        a.setView(2);
                        GameCof.openFCM();
                    }
                });
            };
            e.prototype.checkCanShiMin = function (t, e) {
                var o = this;
                GameBaseManager.requestJson(
                    t + e,
                    function (t) {
                        if (1 == t.code || "实名认证已经通过，不能修改" == t.msg) {
                            o.setView(2);
                            GameBaseManager.sendFirstEnterGame();
                            QReport.send("1005", 1);
                            GameCof.openFCM();
                            GameBaseManager.checkEnterZhuce();
                        } else c.default.open(s.UIID.UIToast, {msg: "认证失败"});
                    },
                    this,
                    "POST"
                );
            };
            e.prototype.isValidIDCard = function (t, e) {
                if (null == t || "" == t || 18 != t.length) return 0;
                t = t.toLocaleLowerCase();
                for (var o = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], a = 0, i = 0; i < o.length; ++i) {
                    var n = parseInt(t[i]);
                    if (null == n) return 0;
                    a += n * o[i];
                }
                var r = a % 11;
                if (t[17] == ["1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2"][r]) {
                    var s = new Date(e),
                        c = parseInt(t.substring(6, 10));
                    return null == c ? 0 : s.getFullYear() - c >= 18 ? 1 : 2;
                }
                return 0;
            };
            e.prototype._onStartGameBtnTouchEnd = function () {
                this.closeUI();
                GameBaseManager.startEnterGame = !0;
            };
            return n([l], e);
        })(r.default));
o.default = d;
